<?php
$SQLconnect = mysql_connect("localhost","indoor","outdoor");
$SQLlist = "SELECT * FROM best_news";
	
if (!$SQLconnect) { echo("SQL Connection Error: " . mysql_error() . "\n");	}

else {
	$SQLexecute = mysql_db_query("indoor",$SQLlist,$SQLconnect);
	if (!$SQLexecute) { echo("SQL Execution Error: " . mysql_error() . "\n$SQL\n");	}
	else {
		while($rowArray = mysql_fetch_array($SQLexecute,MYSQL_ASSOC)) {;
			$bodyString .= "
<div class='best_news_record'>";		$sort_order = $rowArray["sort_order"];
		$timestamp = $rowArray["timestamp"];
		$title = $rowArray["title"];
		$publishDate = $rowArray["publishDate"];
		$body = $rowArray["body"];
		$id = $rowArray["id"];

		$bodyString .= "\n<div class='frontListElement'>Date and Time Published: ".strftime('%m',strtotime($timestamp))." ".strftime('%d',strtotime($timestamp))." ".strftime('%Y',strtotime($timestamp))."</div>";
		$bodyString .= "\n<div class='frontListElement'>Title: $title</div>";
		$bodyString .= "\n<div class='frontListElement'>Date / Month Published: $publishDate</div>";
		$bodyString .= "\n<div class='frontListElement'>Body Text: $body</div>";
	$SQLrelatedData = "SELECT title AS fieldname, id FROM best_newsImages WHERE id = '$images' ";
	$SQLrelatedResult = $db->query($SQLrelatedData);
	while($relatedRowArray = $db->fetch_array($SQLrelatedResult) ) {
		$fieldName = $relatedRowArray["fieldname"];
		$relatedId = $relatedRowArray["id"];
		$bodyString .= "\n<div class='frontListElement'>Images: $fieldName</div>";
	}
	
			$bodyString .= "
</div>";					
		}
	}
}
mysql_close($SQLconnect);
?>
<html>
	<head>
		<title>best_news Front</title>
	<link rel="stylesheet" type="text/css" href="io_cms.css" />
	</head>
	<body><?php echo $bodyString; ?>
	

	</body>
</html>